package com.teach.javafxclient.controller.base;

import com.teach.javafxclient.Globalvar;
import com.teach.javafxclient.util.HttpUtil;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.text.Text;

import kong.unirest.*;
import kong.unirest.json.JSONObject;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author Liang Jianlin
 * @date 2024-04-05 01:07
 */
public class ActivityInfoController {
    @FXML
    Label name;
    @FXML
    Label type;
    @FXML
    Label start;
    @FXML
    Label end;
    @FXML
    Label description;

    public void initialize(){
//        Globalvar.userToken ="eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyMDI0OTk5OSIsImlhdCI6MTcxNzE0MjAxMCwiZXhwIjoxNzE3MTUwNjUwfQ." +
//                "vr1Pl6cAxjroM5ZqZjNJ-8yXxzDCxSiN4xTc8yjTBWj89-KRh29hnGHyU7KPnxzZS-4hEtMAayO6EZRfcUbQAQ";
//        long id=2;
//        String id0= String.valueOf(id);
//        HttpResponse<JsonNode> response = HttpUtil.get(Globalvar.baseUrl + "/api/activities/"+id0)
//                .header("Accept", "application/json")
//                .asJson();
//        JsonNode jsonResponse = response.getBody();
//        System.out.println(jsonResponse.toString());
//        JSONObject jsonObject = jsonResponse.getObject();
//        System.out.println(jsonObject);
//        String name0=jsonObject.getString("name");
//        String type0=jsonObject.getString("type");
//        String start0=jsonObject.getString("start");
//        String end0=jsonObject.getString("end");
//        String description0=jsonObject.getString("description");
//        name.setText(name0);
//        if (type0.equals("CONTEST")) {
//            type.setText("活动类型：竞赛");
//        } else {
//            type.setText("活动类型：志愿活动");
//        }
//        description.setWrapText(true);
//        description.setText("活动简介："+description0);
//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
//        LocalDateTime startDateTime = LocalDateTime.parse(start0, formatter);
//        LocalDateTime endDateTime = LocalDateTime.parse(end0, formatter);
//        DateTimeFormatter displayFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        start.setText("开始时间："+startDateTime.format(displayFormatter));
//        end.setText("结束时间："+endDateTime.format(displayFormatter));
    }
}



